using System;
using Castle.ActiveRecord;
using Castle.Components.Validator;
using Query;
using Rhino.Commons;
using WineCellar.Data;

namespace WineCellar.Data
{
	[ActiveRecord("Cellar", Schema = "dbo", UseAutoImport = false)]
	public class Cellar
	{
		#region Private members
		private string name;       
		private Nullable<DateTime> dateAdded;
		private Nullable<int> id;			    
		private User user;
		#endregion

		#region Public properties		
		
		[Property("Name", ColumnType = "String")]
		[ValidateNonEmpty("Name is a required field")]
		public virtual string Name
        {
			get{return this.name;}
			set{this.name = value;}
		}
		
		[Property("DateAdded", ColumnType = "Timestamp")]
		public virtual Nullable<DateTime> DateAdded
        {
			get{return this.dateAdded;}
			set{this.dateAdded = value;}
		}
		[PrimaryKey(PrimaryKeyType.Identity)]		
		public virtual Nullable<int> Id
		{
			get{return this.id;}
			set{this.id = value;}
		}
		
		[BelongsTo("UserId",NotNull = true)]
		public virtual User User
		{
			get{return this.user;}
			set{this.user = value;}
		}
		#endregion

		
        public override string ToString()
        {
            return Name;
        }
    }
}
   